package org.uni_hi.lsep.gui.test.sim;

import java.awt.Color;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import org.uni_hi.lsep.gui.util.BackgroundImagePanel;
import org.uni_hi.lsep.gui.util.Config;

public class IconContainer extends BackgroundImagePanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ImageIcon _mailIcon=null;
	private JLabel _title=null;
	private JLabel _ip_address=null;
	private JLabel _transferStatus=null;
//	private final double _resize=0.75;
//	
	private int _spacer=3;
	
	public IconContainer(String path, String title, String ip_address){
		super(null,path);
//		getPanel().setOpaque(false);
		getPanel().setBackground(Color.WHITE);
		_mailIcon=new ImageIcon(Config.simMailSrc);
		
		_title=new JLabel(title);
		_title.setBackground(Color.WHITE);
		_title.setSize(150, 10);
		getPanel().add(_title);
		
		_ip_address=new JLabel(ip_address);
		_ip_address.setBackground(Color.WHITE);
		_ip_address.setSize(150, 10);
		getPanel().add(_ip_address);
		
		_transferStatus=new JLabel(_mailIcon);
		_transferStatus.setBounds(60, 50, _mailIcon.getIconWidth(),_mailIcon.getIconHeight());
		getPanel().add(_transferStatus);
		getPanel().setComponentZOrder(_transferStatus, 0);
		_transferStatus.setVisible(false);
		
		_title.setLocation(0, getBGImage().getHeight(getPanel())+_spacer);
		_ip_address.setLocation(0, _title.getY()+_title.getHeight()+_spacer);
		
		getPanel().setSize(120, _ip_address.getY()+_ip_address.getHeight()+_spacer);
		getPanel().setPreferredSize(getPanel().getSize());
//		showSymbol();
//		startAnimation();
	}
	
	public void setIPAddress(String ip){
		_ip_address.setText(ip);
	}
	
	public void showSymbol(){
		_transferStatus.setVisible(true);
		getPanel().updateUI();
	}
	
	public void setBGImage(ImageIcon i){
		super.setBGImage(i.getImage());
	}
}
